<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="stylesheet" href="../css/index.css">
<script src="../js/jquery-3.2.1.js"></script>
<body>
<div class="login">
<div class="login-item">
    <input type="text" id="username" placeholder="username">
    <input type="text" id="password" placeholder="password">
    <button class="button" onclick="login()">Login</button>
</div>
</div>
<div class="float-bg"></div>
</body>
<script>
    function login()
    {
        var username = $("#username");
        var password = $("password");

        $.ajax(
            {
                type: "POST",
                contentType: "application/json",
                data:JSON.stringify({"username":username,"password":password})
                success:function (data)
                {
                    if(data.code==200)
                    {
                        alert("登录成功");
                    }else if (data.code==400)
                    {
                        alert("用户名或密码错误");
                    }
                }
            }
        );
    }
</script>
</html>
